package com.qf.ssm.controller;

import com.qf.ssm.entity.order.*;
import com.qf.ssm.entity.user.User;
import com.qf.ssm.service.OrderService;
import com.qf.ssm.utils.ResponseResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hzy
 * @DATE 2021/2/25
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    OrderService orderService;

    /*
    * 订单列表展示
    * */
    @GetMapping("/query/orderlist")
    private ResponseResult<List<OrderMessage>> queryOrderlist(){
        ResponseResult<List<OrderMessage>> result = orderService.selectOrderList();
        return result;
    }

    /*
    * 根据订单编号查询订单详情
    * */

    @GetMapping("/query/orderDetail")
    private ResponseResult<OrderMessage>queryOrderDetail(String orderNums){
        ResponseResult<OrderMessage> result = orderService.seletOrderDetail(orderNums);
        return result;
    }
    /*
    * 用户添加订单
    * 返回影响行数
    * */
    @PostMapping("/add/order")
    private ResponseResult<Integer>addOrderByUserId(@RequestBody OrderMessage orderMessage){
        ResponseResult<Integer> result = orderService.insertOrderMessage(orderMessage);
        return result;
    }
    /*
    * 用户取消订单，假删除
    * */

    @PostMapping("delete/userOrdermessage")
    private ResponseResult<Integer>deleteUserOrderMessage(@RequestBody OrderMessage orderMessage){
        return orderService.updateOrderMessage(orderMessage);
    }

    /*
    * 用户地址添加
    * */

    @PostMapping("/add/userAddress")
    private ResponseResult<Integer>addUserAddress(@RequestBody UserAddress userAddress){
        return orderService.insertUserAddress(userAddress);
    }

    /*
    * 用户地址修改
    * */
    @PostMapping("/modify/userAddress")
    private ResponseResult<Integer>modifyUserAddress(@RequestBody UserAddress userAddress){
        return orderService.updateUserAddress(userAddress);
    }

    /*
    * 用户地址删除，假删除
    * */

    @PostMapping("/delete/userAddress")
    private ResponseResult<Integer>deleteUserAddress(@RequestBody UserAddress userAddress){
        return orderService.updateUserStatus(userAddress);
    }
    /*
    * 根据名字查询物流公司
    * */

    @GetMapping("/company")
    private ResponseResult<LogisticsCompany>queryCompanyByname(String companyName){
        return orderService.selectCompanyByName(companyName);
    }
    /*
    * 根据区域查询物流公司*/
    @GetMapping("/networkCity")
    private ResponseResult<List<CooperativeNetwork>>queryNetworkByCity(String networkcity){
        return orderService.selectNetworkBycity(networkcity);
    }

    /*
    * 添加合作网点
    * */
    @PostMapping("/add/CON")
    private ResponseResult<Integer>addNetwork(@RequestBody CooperativeNetwork cooperativeNetwork){
        return orderService.insertCooperativeNet(cooperativeNetwork);

    }
    /*
    * 根据物流公司id查询物流合作网点
    * */
    @GetMapping("/shipping")
    private ResponseResult<List<ShippingTime>>queryShipByCnid(int cnid){
        return orderService.selectShipByCnid(cnid);
    }

    /*
    * 根据物流公司划区查询区域仓库情况
    * */
    @GetMapping("/logisticsArea")
    private ResponseResult<List<RegionalLogistics>>queryByAreaName(String areaName){
        return orderService.selectAreaByName(areaName);
    }

    /*
    * rl_id配置物流的信息
    * */
    @GetMapping("/logisticsConfig")
    private ResponseResult<List<RegionalLogistics>>queryLogisticsConfigByRlid(int rlId){
        return orderService.selectLogisticsConfigByrlId(rlId);
    }
}
